/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, LineColumn, InputLine, TextArea, BlobInputList,  CheckSwitch,} from "customize-easy-ui-component";
import {
    InspectRecordLayout, InternalItemProps,  useItemInputControl,
} from "../common/base";
import {useMeasureInpFilter} from "../common/hooks";
import {usePrefixDataEdit} from "../hook/usePrefixData";
import {config资料审查} from "./impsaf/orcBase";

interface Props  extends InternalItemProps{
    label?: string;
    titles?: any[];
}


/**资料审查主体  config={config资料审查}
 * */
export const MaterialReview=
React.forwardRef((
    { children, show ,alone=true,redId,nestMd,label,titles}:Props,  ref
) => {
    const {inp, setInp} = useItemInputControl({ref});
    const [renderEditline, itemA审查概况] = usePrefixDataEdit({
        inp, setInp, config: config资料审查,  });
    const [getInpFilter] = useMeasureInpFilter(null, itemA审查概况,);
    return <InspectRecordLayout inp={inp} setInp={setInp} getInpFilter={getInpFilter} show={show} redId={redId}
                                nestMd={nestMd} alone={alone} label={label!}>
        <Text variant="h5">{label}：</Text>
        资料审查设备概况除在台账业务信息中可修改外还需修改的部分:
        {renderEditline}
        { children }
    </InspectRecordLayout>;
});


export const item查材料o=[['合格证','产品合格证'],['元材证','主要受压元件材质证明'],['焊试件','产品焊接试件'],['无损报','无损检测报告'],
         ['热处报','热处理报告'],['压试报','压力试验报告'],['漏试报','泄漏试验报告'],['外尺报','外观及几何尺寸检验报告'],];
export const itemA查材料: string[]=['制造许证','设计件','审查结论'];
item查材料o.forEach(([name,], i:number)=>{
    itemA查材料.push(name as string);
});
// export const itemA上次问题: string[]=['上次报告','上次评级','上次缺处']; FactoryMaterial
export const FactoryMaterial=
    React.forwardRef((
        { children, show ,alone=true,redId,nestMd,label,titles}:Props,  ref
    ) => {
        const [getInpFilter]=useMeasureInpFilter(null,itemA查材料,);
        const {inp, setInp} = useItemInputControl({ ref });
        return <InspectRecordLayout inp={inp} setInp={setInp} getInpFilter={getInpFilter} show={show} redId={redId}
                                    nestMd={nestMd} alone={alone} label={label!}>
            <Text variant="h5">{label}：</Text>
            资料审查-资料审查情况
            <LineColumn>
                <InputLine label={'特种设备制造许可证复印件,证书号：'}>
                    <BlobInputList value={inp?.制造许证 || ''} rows={1} datalist={['TS ,在许可证范围内']}
                                   onListChange={v => setInp({...inp, 制造许证: v || undefined})}/>
                </InputLine>
                <InputLine label={'设计文件审查：'}>
                    <BlobInputList value={inp?.设计件 || ''} rows={1} datalist={['齐全']}
                                   onListChange={v => setInp({...inp, 设计件: v || undefined})}/>
                </InputLine>
            </LineColumn>
            <Text variant="h6">出厂（竣工）材料：</Text>
            <LineColumn column={5}>
                {item查材料o.map(([name, desc]: any, i: number) => {
                    return <InputLine key={i} label={`${desc}:`}>
                        <CheckSwitch checked={inp?.[name] || false}
                                     onChange={e => setInp({...inp, [name]: inp?.[name] ? undefined : true})}/>
                    </InputLine>;
                })}
            </LineColumn>
            资料审查的结论：
            <TextArea value={inp?.审查结论 || ''} rows={7}
                      onChange={e => setInp({...inp, 审查结论: e.currentTarget.value || undefined})}/>
        </InspectRecordLayout>;
    });

